"""
	测试
"""


class SkillData:
	"""技能数据"""

	def __init__(self, ids, name, atk_ratio, duration):
		self.ids = ids
		self.name = name
		self.atk_ratio = atk_ratio
		self.duration = duration

	def __str__(self):
		return f"{self.ids}, {self.name}, {self.atk_ratio}, {self.duration}"


# 不是重点
list1 = [
	SkillData(101, "乾坤大挪移", 5, 10),
	SkillData(102, "葵花宝典", 8, 5),
	SkillData(103, "降龙十八掌", 10, 2)
]


# 变化点
def condition1(info):
	return info.atk_ratio > 6


def condition2(info):
	return 4 <= info.atk_ratio <= 6


def condition3(info):
	return len(info.name) > 4 and info.atk_ratio < 6


from 函数式编程应用.list_helper import ListHelper

for item in ListHelper.find_all(list1, condition2):
	print(item)

# 不用condition1-3的方法,用lambda表达式
for it in ListHelper.find_all(list1, lambda so: 4 <= so.atk_ratio <= 6):
	print(it)

print('找到对象name为葵花宝典')
for it in ListHelper.find_all(list1, lambda so: so.name == '葵花宝典'):
	print(it)

print('计算技能列表中技能名称大于4个字的所有技能数量')
for it in ListHelper.find_all(list1, lambda so: len(so.name) > 4):
	print(it)

print("技能持续时间小于等于5的技能数量")
for it in ListHelper.find_all(list1, lambda so: so.duration <= 5):
	print(it)
